﻿<%@ Page Title="Planning" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="ProjectsList.aspx.cs" Inherits="APMAWebConsole.SettingsPart.ProjectsList" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Projects List
    </h2>

    <asp:Button ID="btnAddProject" runat="server" Text="Add Project" OnCommand="OnButtonCommand" CommandName="Add"/>
    <asp:Button ID="btnRemoveProject" runat="server" Text="Remove Project" OnCommand="OnButtonCommand" CommandName="Remove" Visible="false"/>
    <asp:Button ID="btnEditProject" runat="server" Text="Edit Project" OnCommand="OnButtonCommand" CommandName="Edit" Visible="false"/>
    <asp:Button ID="btnBackToList" runat="server" Text="Back to Project List" OnCommand="OnButtonCommand" CommandName="BackToList" CausesValidation="False"/>
        
    <div id="divProjectsGrid" runat="server">
        <p>
            <asp:Label ID="lblSelectedProject" runat="server" AssociatedControlID="txtSelectedProject" Text="Selected Project ID:" Visible="false" />
            <asp:TextBox ID="txtSelectedProject" runat="server" CssClass="textEntry" Text="0" Visible="false" />
        </p>
        <asp:GridView ID="grdProjectsList" runat="server" AutoGenerateColumns="false">
            <columns>
                <asp:BoundField HeaderText="ID" DataField="Id" />
                
                <asp:TemplateField HeaderText="" ShowHeader="False">
                    <ItemTemplate>
                        <asp:Button ID="btnEdit" runat="server" CausesValidation="false" Text="Edit" OnCommand="OnButtonCommand" CommandName="Select" CommandArgument='<%# Container.DataItemIndex + 1 %>'/>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:TemplateField HeaderText="" ShowHeader="False">
                    <ItemTemplate>
                        <asp:Button ID="btnRemove" runat="server" CausesValidation="false" Text="X" OnCommand="OnButtonCommand" CommandName="Remove" CommandArgument='<%# Container.DataItemIndex + 1 %>'/>
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField HeaderText="Name" DataField="Name" />
            </columns>
        </asp:GridView>
    </div>
        
    <div id="divEditMode" runat="server">
        <p>
            <asp:Label ID="lblProjectId" runat="server" AssociatedControlID="txtProjectId">ID:</asp:Label>
            <asp:TextBox ID="txtProjectId" runat="server" CssClass="textEntry"></asp:TextBox>
        </p>
        <p>
            <asp:Label ID="lblProjectName" runat="server" AssociatedControlID="txtProjectName">Name:</asp:Label>
            <asp:TextBox ID="txtProjectName" runat="server" CssClass="textEntry"></asp:TextBox>
            <asp:RequiredFieldValidator id="rfvProjectName" runat="server"
                                        ControlToValidate="txtProjectName"
                                        ErrorMessage=" * Project Name is a required field."
                                        ForeColor="Red"/>
            <br/>
            <asp:RegularExpressionValidator id="revProjectName" runat="server" SetFocusOnError="True"
                                            ErrorMessage="Project Name length must be between 3 and 50 characters" Display="Dynamic"
                                            ControlToValidate="txtProjectName" ValidationExpression="^[\s\S]{3,50}$"/>
        </p>

        <asp:Button ID="btnCreateUpdate" runat="server" Text="Save" OnCommand="OnButtonCommand" CommandName="SaveUpdate"/>

    </div>
</asp:Content>
